package com.sj.pojo;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author xiaoqi
 */

@AllArgsConstructor
@Getter
public enum MsgTypeEnum {

    REQUEST((byte) 1),

    RESPONSE((byte) 2);

    private byte code;

    public static MsgTypeEnum getMessageTypeEnumByCode(int code) {
        return Arrays.stream(MsgTypeEnum.values())
                .filter(e -> e.getCode() == code)
                .findFirst()
                .orElseGet(null);
    }

}
